package com.uyaer.card.vo.soilder
{
	public class SoilderVo
	{
		private var _type:String;
		private var _name:String;
		private var _desc:String;
		private var _level:int;
		private var _rang:int;
		private var _cd:int;
		/**
		 * 是否是同一方人员
		 */		
		public var isMyself:Boolean = true;
		//		public var 宝石
		private var _maxAttack:int;
		private var _maxDefens:int;
		private var _maxHp:int;
		private var _maxSpeed:int;
		private var _maxAttackDelay:int;
		private var _attack:int;
		private var _defens:int;
		private var _hp:int;
		private var _speed:int;
		private var _attackDelay:int;
		private var _attackBuff:int;
		private var _defensBuff:int;
		private var _hpBuff:int;
		private var _speedBuff:int;
		private var _attackDelayBuff:int;
		
		private var _skill:SkillVo;		

		private var sampleVo:SoilderSampleVo;
		private var rankVo:SoilderRankVo;
		public function SoilderVo(type:String = null)
		{
			this._type = type;
			sampleVo = SoilderDataManager.i.soilderSampleMap.get(type);
		}
		
		/**
		 *复制未参加战斗时的基本数据 
		 * @return 
		 * 
		 */		
		public function clone():SoilderVo{
			var so:SoilderVo = new SoilderVo(this.type);
			so._maxAttack = this.maxAttack;
			so._maxDefens = this.maxDefens;
			so._maxHp = this.maxHp;
			so._maxSpeed = this.maxSpeed;
			so._maxAttackDelay = this.maxAttackDelay;
			so._level = this.level;
			so._rang = this.rang;
			so._cd = this.cd;
			so.isMyself = this.isMyself;
			return so;
		}
		
		/**
		 *从根据服务器数据填充本地vo
		 * 
		 */		
		public function fillVoFromServerData(data:Object):void{
			//to do..
			this._type = data.type;
			//to do...获取宝石  
			this._level = data.level;
			
			//获得模版数据
			sampleVo = SoilderDataManager.i.soilderSampleMap.get(type);
			
			this.reCalcAttr();
		}
		
		/**
		 *重新计算属性数据 
		 * 
		 */		
		private function reCalcAttr():void{
			this._maxAttack = sampleVo.attack + (this.level-1)*sampleVo.attackGrow;
			this._maxDefens = sampleVo.defens + (this.level-1)*sampleVo.defensGrow;
			this._maxHp = sampleVo.hp + (this.level-1)*sampleVo.hpGrow;
			this._maxSpeed = sampleVo.speed + (this.level-1)*sampleVo.speedGrow;
			this._maxAttackDelay = sampleVo.attackDelay;
			this._cd = sampleVo.cd;
			this._rang = sampleVo.rang;
			rankVo = SoilderDataManager.i.getSoilderRankInfo(_type,_level);
			this._name = rankVo.name;
			this._desc = rankVo.desc;
			this._skill = SoilderDataManager.i.getSkill(rankVo.skillId);
		}

		/**
		 *类型  
		 */
		public function get type():String{
			return _type;
		}

		/**
		 *等级 
		 */
		public function get level():int{
			return _level;
		}

		/**
		 * @private
		 */
		public function set level(value:int):void{
			_level = value;
			this.reCalcAttr();
		}

		/**
		 *攻击范围 
		 */
		public function get rang():int{
			return _rang;
		}

		/**
		 *当前等级标准攻击力 +永久宝石等加成
		 */
		public function get maxAttack():int{
			return _maxAttack;
		}

		/**
		 *当前等级标准防御力+永久宝石等加成
		 */
		public function get maxDefens():int{
			return _maxDefens;
		}

		/**
		 *当前等级标准生命+永久宝石等加成
		 */
		public function get maxHp():int{
			return _maxHp;
		}

		/**
		 *当前等级标准移动速度+永久宝石等加成
		 */
		public function get maxSpeed():int{
			return _maxSpeed;
		}

		/**
		 * 当前等级标准攻击速度（毫秒）相应的，其攻击速度=1000/maxAttackDelay,攻击速度仅用于显示，不缓存，用时直接计算
		 */
		public function get maxAttackDelay():int{
			return _maxAttackDelay;
		}

		/**
		 *当前攻击力（战斗使用） 
		 */
		public function get attack():int{
			return _maxAttack+_attackBuff;
		}

		/**
		 *当前防御力（战斗使用） 
		 */
		public function get defens():int{
			return _maxDefens+_defensBuff;
		}

		/**
		 *当前生命（战斗使用） 
		 */
		public function get hp():int{
			return _maxHp+_hpBuff;
		}

		/**
		 *当前移动速度（战斗使用） 
		 */
		public function get speed():int{
			return _maxSpeed+_speedBuff;
		}

		/**
		 *当前攻击速度（战斗使用） 
		 */
		public function get attackDelay():int{
			return _maxAttackDelay+_attackDelayBuff;
		}

		/**
		 *buff增加或者减少的当前攻击力（战斗使用） 
		 */
		public function get attackBuff():int{
			return _attackBuff;
		}

		/**
		 * @private
		 */
		public function addAttackBuff(value:int):void{
			_attackBuff += value;
		}

		/**
		 *buff增加或者减少的当前防御力（战斗使用） 
		 */
		public function get defensBuff():int{
			return _defensBuff;
		}

		/**
		 * @private
		 */
		public function addDefensBuff(value:int):void{
			_defensBuff += value;
		}

		/**
		 *buff增加或者减少的当前生命（战斗使用） 
		 */
		public function get hpBuff():int{
			return _hpBuff;
		}

		/**
		 * @private
		 */
		public function addHpBuff(value:int):void{
			_hpBuff += value;
		}

		/**
		 *buff增加或者减少的当前移动速度（战斗使用） 
		 */
		public function get speedBuff():int{
			return _speedBuff;
		}

		/**
		 * @private
		 */
		public function addSpeedBuff(value:int):void{
			_speedBuff += value;
		}

		/**
		 *buff增加或者减少的攻击速度（战斗使用） 
		 */
		public function get attackDelayBuff():int{
			return _attackDelayBuff;
		}

		/**
		 * @private
		 */
		public function addAttackDelayBuff(value:int):void{
			_attackDelayBuff += value;
		}

		/**
		 *士兵名称，等级提升，重新读取配置表获得新名称 
		 */
		public function get name():String{
			return _name;
		}

		/**
		 *描述,兵种说明  
		 */
		public function get desc():String{
			return _desc;
		}

		/**
		 *当前等级的士兵的技能信息，skill=null时，表示当前等级士兵没有技能 
		 */
		public function get skill():SkillVo{
			return _skill;
		}

		/**
		 *出战冷却时间，毫秒计时 
		 */
		public function get cd():int{
			return _cd;
		}


	}
}